package fr.tvbarthel.games.chasewhisply.model;

import android.graphics.Bitmap;
import android.os.Parcel;
import android.os.Parcelable;

/**
 *
 */
public class DisplayableItem implements Parcelable {
    // x coordinate
    protected float mX;
    // y coordinate
    protected float mY;

    protected  float mZ;
    // tells if the item is active/visible
    protected boolean mIsVisible;
    // type
    protected int mType;

    protected Bitmap mGhostBitmap ;

    public int bitmapID;

    public DisplayableItem() {
        mX = 0;
        mY = 0;
        mZ = 0;
        mType = 0;

    }

    public DisplayableItem(float x, float y, float z, int type) {
        mX = x;
        mY = y;
        mZ = z;
        mType = type;
    }

    protected DisplayableItem(Parcel in) {
        readFromParcel(in);
    }


    public void SetGhostBitmap( Bitmap bitmap) {
        mGhostBitmap = bitmap ;
    }

    public final Bitmap GetGhostBitmap(  )
    {
        return mGhostBitmap ;
    }

    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel out, int i) {
        out.writeFloat(mX);
        out.writeFloat(mY);
        out.writeFloat(mZ);
        out.writeByte((byte) (mIsVisible ? 1 : 0));
    }

    /**
     * read parameters from a given Parcel
     *
     * @param in input Parcel to read from
     */
    public void readFromParcel(Parcel in) {
        this.mX = in.readInt();
        this.mY = in.readInt();
        this.mZ = in.readInt();
        this.mIsVisible = in.readByte() == 1;
    }

    public static final Parcelable.Creator<DisplayableItem> CREATOR = new Parcelable.Creator<DisplayableItem>() {
        public DisplayableItem createFromParcel(Parcel in) {
            return new DisplayableItem(in);
        }

        public DisplayableItem[] newArray(int size) {
            return new DisplayableItem[size];
        }
    };

    /**
     * Getters and Setters
     */
    public float getX() {
        return mX;
    }

    public void setX(float mX) {
        this.mX = mX;
    }

    public float getY() {
        return mY;
    }

    public void setY(float mY) {
        this.mY = mY;
    }

    public float getZ() {
        return mZ;
    }

    public void setZ(float mZ) {
        this.mZ = mZ;
    }

    public boolean isActive() {
        return mIsVisible;
    }

    public void setActive(boolean active) {
        mIsVisible = active;
    }

    public void setType(int type) {
        mType = type;
    }

    public int getType() {
        return mType;
    }

    public void setRandomCoordinates(float xMin, float xMax, float yMin, float yMax ,float z)
    {
        setX(MathUtils.randomize(xMin, xMax));
        setY(MathUtils.randomize(yMin, yMax));
        setZ(z);

    }
}
